﻿using System;
using System.Collections.Generic;
using ContractManager.Entity;
using Speed.Data;

namespace ContractManager.BLL.Business
{
    public static class ClsWorkType
    {
        public static List<WorkType> SelectAll()
        {
            using (var db = Sys.NewDb())
            {
                return Data.Base.WorkType.Select(db);
            }
            
        }

        public static void Insert(WorkType capital)
        {
            using (var db = Sys.NewDb())
            {
                db.Insert<WorkType>(capital, EnumSaveMode.Requery);
            }
            
        }

        public static void Update(WorkType capital)
        {
            using (var db = Sys.NewDb())
            {
                db.Update<WorkType>(capital);
            }
            
        }

        public static WorkType SelectByPk(Int32 workId)
        {
            using (var db = Sys.NewDb())
            {
                return db.SelectSingle<WorkType>(string.Format("WorkId={0}", workId));
            }
            
        }

        public static WorkType SelectByCode(string workCode)
        {
            using (var db = Sys.NewDb())
            {
                return db.SelectSingle<WorkType>(string.Format("WorkCode='{0}'", workCode));
            }
           
        }

        public static int DeleteByPk(Int32 workId)
        {
            using (var db = Sys.NewDb())
            {
                return db.Delete<WorkType>(string.Format("WorkId={0}", workId));
            }
            
        }
    }
}
